import React, {Component} from 'react'
import {
    StyleSheet, Text,
    View, Image, TouchableOpacity,
    Dimensions, ScrollView
} from 'react-native'
import Neadygridviewpageitem from './neadygridviewpageitem'
import PageControl from './PageControl'
let {height, width} = Dimensions.get('window');

export default class neardygridviewpage extends Component {
    constructor(props) {
        super(props)
        this.state = {
            currentPage: 0
        }
    }

    render() {
        let {menuInfos} = this.props;
        let menuItems = menuInfos.map(
            (info, i) => (<Neadygridviewpageitem
                    key={info.str}
                    title={info.str}

                />
            )
        );
        let menuViews = []
        let pageCount = 2

        for (let i = 0; i < pageCount; i++) {
            let length = menuItems.length < (i * 10) ? menuItems.length - (i * 10) : 10;
            let items = menuItems.slice(i * 10, i * 10 + length);
            let menuView = (
                <View style={styles.itemsView} key={i}>
                    {items}
                </View>
            )
            menuViews.push(menuView)
        }
        return (
            <View style={styles.container1}>
                <View style={styles.menuContainer}>
                    {menuViews}
                </View>
            </View>
        );
    }


}

const styles = StyleSheet.create({
    container1: {
        backgroundColor: 'white',
        flexDirection: 'column',
    },
    contentContainer: {
        paddingTop: 10
    },
    menuContainer: {
        flexDirection: 'row',
    },
    itemsView: {
        flexDirection: 'row',
        flexWrap: 'wrap',
        width: width,
        backgroundColor:'#F3F3F3',
        paddingRight:5,
        paddingLeft:5,
        paddingBottom:5
    },
    pageControl: {
        margin: 10,
    },
    pageViewStyle: {
        width: width,
        height: 25,
        backgroundColor: '#fff',
        // 设置主轴的方向
        flexDirection: 'row',
        // 设置侧轴方向的对齐方式
        alignItems: 'center',
        justifyContent: 'center'
    }
});

module.exports = neardygridviewpage